
A$LocalLanguage = NA
A$LocalLanguage[which(A$City == 'Bangalore')] = A$C.C10_Mother.Tongue.[which(A$City == 'Bangalore')] == 'Kannada'
A$LocalLanguage[which(A$City == 'Jaipur')] = A$C.C10_Mother.Tongue.[which(A$City == 'Jaipur')] %in% c('Marwari', 'Hindi')
A$LocalLanguage[which(A$City == 'Patna')] = A$C.C10_Mother.Tongue.[which(A$City == 'Patna')] == 'Bihari' | A$C.C10_Mother.Tongue.[which(A$City == 'Patna')] == 'Hindi'  #Note, I'm not sure if Bihari and Hindu are actually different

A$Religion = mapvalues(A$C.C6_Religion, from = c('Christian',     'Hindu',    'Muslim',     'Other'),
                       to = c('Christian','Hindu','Muslim',NA))
A$Muslim = mapvalues(A$Religion, from = c('Christian',     'Hindu',    'Muslim'),
                     to = c('No','No','Yes'))

lm0 = ( lm('ListOut ~ ListFavor*SocDens',
           data = A[which(A$ListTreat != 2),]) ) #
out0 = coeftest(lm0, cluster.vcov(lm0, A[which(A$ListTreat != 2),'A.A7_Area.Neighborhood'] ) )

#TABLE 4: Individual clientelism list with controls
lm5 = ( lm('ListOut ~ ListFavor*SocDens + ListFavor*Age + ListFavor*Male + ListFavor*AssetSum + 
           ListFavor*C.C50_Years.Of.Schooling. + ListFavor*C.C14_Permanent.Residence.of.Jaipur. +
           ListFavor*factor(GenCaste) + ListFavor*factor(LocalLanguage) + ListFavor*factor(Religion)',
           data = A[which(A$ListTreat != 2),]) ) #
out5 = coeftest(lm5, cluster.vcov(lm5, A[which(A$ListTreat != 2),'A.A7_Area.Neighborhood'] ) )

sg_tab3 = stargazer(out0,out5, keep = c('^ListFavor$','^SocDens$','^ListFavor:SocDens$'),
                covariate.labels = c('Individual Clientelism Treatment','Individual Social Connectedness',
                                     'Treatment * Connectedness'),
                dep.var.caption = "", header = F,
                add.lines = list( c("Demographic Controls", "No", "Yes"),
                                  c("N", nobs(lm0),nobs(lm5)),
                                  c('$R^2$',
                                    round(summary(lm0)$r.squared,3),
                                    round(summary(lm5)$r.squared,3))
                                  ) ,
                title = 'List experiment: Individual social connectedness and individual clientelism',
                label = 'inde_client_list')
writeLines(sg_tab3, con = paste0('../results/T4_',(Sys.time() %>% str_replace_all(c(":" = "-", " " = "_"))),'.tex')); rm(sg_tab3)

#Table F1
sg_tab3_ctrl = stargazer(out0,out5, keep = c('^ListFavor$','^SocDens$','^ListFavor:SocDens$',
                                             'Age','Male','AssetSum','C.C50_Years.Of.Schooling.',
                                             'C.C14_Permanent.Residence.of.Jaipur.',
                                             'factor(Religion)Hindu','factor(Religion)Muslim'),
                         covariate.labels = c('Individual Clientelism Treatment','Individual Social Connectedness',
                                              'Age','Male','Assets','Education','Permanent Resident',
                                              'Treatment * Connectedness',
                                              'Treatment * Age', 'Treatment * Male', 'Treatment * Assets',
                                              'Treatment * Education', 'Treatment * Perm. Res.'),
                dep.var.caption = "", header = F,
                add.lines = list( c("Caste, Religion, and Language", "No", "Yes"),
                                  c("N", nobs(lm0),nobs(lm5)),
                                  c('$R^2$',
                                    round(summary(lm0)$r.squared,3),
                                    round(summary(lm5)$r.squared,3))
                ) ,
                title = 'List experiment: Individual social connectedness and individual clientelism',
                label = 'inde_client_list_ctrl')
writeLines(sg_tab3_ctrl,con = paste0('../results/F1_',(Sys.time() %>% str_replace_all(c(":" = "-", " " = "_"))),'.tex')); rm(sg_tab3_ctrl)